package aad.storyboard.model;

public abstract class StoryComponent {
	
	 protected StoryComponentState stoppedState;
	 protected StoryComponentState startedState;
	 protected StoryComponentState currentState;
	 
	 protected int startTime;
	 protected int endTime;
	 protected int duration;
	 protected int id;
	 
	 public StoryComponent(int id,int startTime)
	 {
		 this.id = id;
		 this.startTime=startTime;
		 stoppedState=new StoryComponentStoppedState();
		 startedState=new StoryComponentPlayingState();
		 currentState=stoppedState;
	 }
	 
	 public StoryComponent(int id,int startTime,int endTime)
	 {
		 this.id = id;
		 this.startTime=startTime;
		 this.endTime=endTime;
		 duration=startTime+endTime;
		 
		 stoppedState=new StoryComponentStoppedState();
		 startedState=new StoryComponentPlayingState();
		 currentState=stoppedState;
	 }
	 
	 public StoryComponent(int id)
	 {
		 this.id = id;
		 stoppedState=new StoryComponentStoppedState();
		 startedState=new StoryComponentPlayingState();
		 currentState=stoppedState;
	 }
	 
	 public void setDuration(int duration) {
			this.duration = duration;
		}

		public int getDuration() {
			return duration;
		}
		
		public void setStartTime(int start) {
			this.startTime = start;
		}

		public int getStartTime() {
			return startTime;
		}
		
		public int getEndTime() {
			
			return endTime;
		}

		public void setEndTime(int i) {
			endTime=i;
			
		}
		
		public void updateState(int currentTime)
		{			
			currentState.start(currentTime, this);
		}

		public void setNewState(StoryComponentState state)
		{
			currentState=state;
		}
		
		public StoryComponentState getState()
		{
			return currentState;
		}
		
		public StoryComponentState getStartedState()
		{
			return startedState;
		}
		
		public StoryComponentState getStoppedState()
		{
			return stoppedState;
		}

		public int getId() {
			return id;
		}

		public void setId(int id) {
			this.id = id;
		}
		
		
}
